<?php
//$str=file_get_contents('http://www.1905.com/vod/');
////$s=iconv('gbk','UTF-8',$str);
////echo $str;
//$preg='#<!-- 最新大片 -->.*<!-- 最新大片end -->#isU';
//preg_match($preg,$str,$arr);
////print_r($arr);die;
//$preg_aa='#.*<li>.*<div class=".*">.*<a href="(.*)" target="_blank" class=".*" data-hrefexp=".*"><img src=".*" alt="青年马克思"><h3>(.*)</h3>.*<p>(.*)</p></a>.*</div>.*<div class=".*">.*<a href="(.*)" target="_blank" class=".*" data-hrefexp=".*"><img src=".*" alt="金珠玛米"><h3>(.*)</h3>.*<p>(.*)</p></a>.*</div>.*</li>#isU';
//preg_match_all($preg_aa,$arr[0],$arr_gg);
////print_r($arr_gg);die;
//foreach($arr_gg[1] as $key)
$str=file_get_contents('http://www.techweb.com.cn');
//echo $str;
$preg='#<!--移动互联 start-->.*<!--移动互联 end-->#isU';
preg_match($preg,$str,$arr);
//print_r($arr#);
$preg_arr='#<div class="picture_text"><a href=".*" target="_blank"><div class="picture">.*<img id="y01" src="(.*)" alt=\'三大运营商完成提速降费任务：去年让利1200亿元\' title=\'三大运营商完成提速降费任务：去年让利1200亿元\'/>.*</div><h4>(.*)</h4></a></div>.*<div class="picture_text"><a href=".*" target="_blank"><div class="picture">.*<img id="y11" src="(.*)" alt=\'网信办对“简书网”作出行政处罚 约谈负责人\' title=\'网信办对“简书网”作出行政处罚 约谈负责人\'/>.*</div><h4>(.*)</h4></a></div>.*<li><a href="(.*)" target="_blank" title="资讯 |小米真心被黑惨了 发布会上放纵了一把还望理解">(.*)</a></li>.* <div class="picture_text"><a href="http://mi.techweb.com.cn/tmt/2019-01-16/2720729.shtml" target="_blank"><div class="picture">.*<img id="y21" src="(.*)" alt=\'小米股东套现近82亿港元：今年来股价下跌23%\' title=\'小米股东套现近82亿港元：今年来股价下跌23%\'/>.*</div><h4>(.*)</h4></a></div>.*<div class="picture_text"><a href="(.*)" target="_blank"><div class="picture">.*<img id="y31" src="(.*)" alt=\'滴滴征求意见：乘坐网约车需要实名认证吗？\' title=\'滴滴征求意见：乘坐网约车需要实名认证吗？\'/>.*</div><h4>(.*)</h4></a></div>.* <li><a href="(.*)" target="_blank" title="资讯 |京东、苏宁自营iPhone疯狂大降价：真相在此">(.*)</a></li>#isU';
preg_match_all($preg_arr,$arr[0],$ass);
//print_r($ass);die;
foreach($ass[1] as $key=>$value)
{
    $arr_gg['img_url']=$ass[1][$key];
    $arr_gg['img_url']=$ass[3][$key];
    $arr_gg['img_url']=$ass[7][$key];
    $arr_gg['img_url']=$ass[10][$key];
    $arr_gg['title']=$ass[2][$key];
    $arr_gg['title']=$ass[4][$key];
    $arr_gg['title']=$ass[8][$key];
    $arr_gg['title']=$ass[11][$key];
    $arr_gg['content']=$ass[6][$key];
    $arr_gg['content']=$ass[13][$key];
    $dbh=new PDO('mysql:host=localhost;dbname=gaofei','root','root');
    $sql="insert into asd(img_url,title,content) VALUES('{$arr_gg['img_url']}','{$arr_gg['title']}','{$arr_gg['content']}')";
    $dbh->exec($sql);

}


